<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui" >
<h:head>
    <title>Pags</title>
</h:head>
<h:body>
    <h:form id="tabelaProcesso" prependId="false" style="overflow: auto;">
        <p:dataTable var="processo" value="#{filtroBean.listarProcessoPorStatus}" emptyMessage="Não há informações!"
            paginator="true" paginatorPosition="both" rows="15" selectionMode="single" 
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
            rowsPerPageTemplate="5,15,30" style="overflow: auto;">
            <h:inputHidden value="#{processo.idprocesso}" />
            <p:column headerText="Detalhes" style="width: 5%" >
                <center>
                    <p:commandLink title="Detalhes do processo" oncomplete="detalhesProcessoDialog.show();" update="detalhesProcesso"  >
                        <h:graphicImage library="imagens" name="detalhes_16.png" style="border:0"/>
                        <f:setPropertyActionListener target="#{processoBean.processo}" value="#{processo}"  />
                    </p:commandLink>
                </center>
            </p:column>
            <p:column headerText="PAG" filterBy="#{processo.pag}" >
                <center>
                    <h:outputText value="#{processo.pag}" title="Detalhes do processo" />
                </center>
            </p:column>
            <p:column headerText="PAM" filterBy="#{processo.pam}" >
                <center>
                    <h:outputText value="#{processo.pam}" />
                </center>
            </p:column>
            <p:column headerText="OM solicitante" >
                <center>
                    <h:outputText value="#{processo.unidadeSolicitante}" >
                        <f:converter converterId="ConverteUnidadeMilitarSiglaId"/>
                    </h:outputText>
                </center>
            </p:column>
            <p:column headerText="Setor solicitante" >
                <center>
                    <h:outputText value="#{processo.setorSolicitante}" >
                        <f:converter converterId="ConverteSetorSiglaId"/>
                    </h:outputText>
                </center>
            </p:column>
            <p:column headerText="Objeto" style="width: 25%">
                <center>
                    <h:outputText value="#{processo.objeto}" />
                </center>
            </p:column>
            <p:column headerText="Doc." >
                <center>
                    <p:commandLink ajax="false" immediate="true" onclick="if (!confirm('Confirma baixar o PAG nº #{processo.pag}?')) return false;" rendered="#{processo.arquivo == true}" >
                        <f:setPropertyActionListener target="#{processoBean.processo}" value="#{processo}" />
                        <p:fileDownload value="#{processoBean.arquivoRetornoPAG}" contentDisposition="inline" />
                        <h:graphicImage library="imagens" name="pdf_#{processo.arquivo}.png" style="border:0;" title="Presente"/>
                    </p:commandLink>
                    <p:commandLink disabled="true" rendered="#{processo.arquivo == false}" >
                        <h:graphicImage library="imagens" name="pdf_#{processo.arquivo}.png" style="border:0" title="Ausente" />
                    </p:commandLink>
                </center>
            </p:column>
            <p:column headerText="Status" style="width: 8%" >
                <center>
                    <h:outputText value="Ativo" rendered="#{processo.status == 1}" style="color: green;" />
                    <h:outputText value="Arquivado" rendered="#{processo.status == 2}" style="color: red;" />
                </center>
            </p:column>
            <p:column>
                <center>
                    <p:commandButton value="Volumes" immediate="true"  update="tabelaVolumes2" image="ui-icon ui-icon-newwin" onclick="volumeDialog.show()" >
                        <f:setPropertyActionListener target="#{volumeProcessoBean.processoSelecionado}" value="#{processo.idprocesso}" />
                        <f:setPropertyActionListener target="#{volumeProcessoBean.status}" value="#{processo.status}" />
                    </p:commandButton>
                </center>
            </p:column> 
            <p:column>
                <center>
                    <p:commandButton value="Anexos"  update="tabelaAnexos2" image="ui-icon ui-icon-newwin" onclick="anexoDialog.show()" >
                        <f:setPropertyActionListener target="#{anexoProcessoBean.processoSelecionado}" value="#{processo.idprocesso}" />
                        <f:setPropertyActionListener target="#{anexoProcessoBean.status}" value="#{processo.status}" />
                    </p:commandButton>
                </center>
            </p:column>
        </p:dataTable>
    </h:form>
</h:body>
</html>